package com.lmf;

import com.lmf.config.SpringContextUtil;
import com.lmf.config.ZuulFallbackProviders;
import com.lmf.filter.ErrortFilter;
import com.lmf.filter.TokenFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableZuulProxy
@RestController
public class ZuulApplication {

	public static void main(String[] args) {
		SpringApplication.run(ZuulApplication.class, args);
	}
	//过滤器
	@Bean
	public TokenFilter tokenFilter(){

		return new TokenFilter();
	}

	@GetMapping("/test")
	public String test(){
		ApplicationContext applicationContext=SpringContextUtil.getApplicationContext();
	/*	String[] names=applicationContext.getBeanDefinitionNames();*/
		/*for(String name:names){
			System.out.println(name);
		}*/
		Object object=applicationContext.getBean("zuulFallbackProviders");
		System.out.println(object.getClass());
		return "ok";

	}
	@GetMapping("/error")
	public String error(){
		return "发生错误了哟";
	}

}
